package cn.bigcontainer.alt.common.exception;

/**
 * 项目异常类
 * @author cailei
 * 
 */
public class BigException extends RuntimeException {

	/**
	 *
	 */
	private static final long serialVersionUID = -5680000136411496594L;

	public final static BigResultCode ERROR_UNKNOWN = new BigResultCode(0, "未知错误");
	//
	public final static BigResultCode ERROR_NOT_ALLOWED = new BigResultCode(6, "该操作不允许执行！");
	public final static BigResultCode ERROR_DUPLICATE = new BigResultCode(7, "数据重复：%s，%s！");
	public final static BigResultCode ERROR_QUERY = new BigResultCode(8, "未获取到[%s]的数据！");
	public final static BigResultCode ERROR_NULL = new BigResultCode(9, "[%s]不能为空！");
	public final static BigResultCode ERROR_DT_PARSE = new BigResultCode(10, "解析时间字符串[%s]出错！");
	public final static BigResultCode ERROR_DT_NULL = new BigResultCode(11, "时间字符串不能为空！");
	public final static BigResultCode ERROR_NOT_SAME = new BigResultCode(12, "[%s]和[%s]不一致！");
	public final static BigResultCode ERROR_RELATED = new BigResultCode(13, "有关联数据：%s！");

	//
	public final static BigResultCode ERROR_JSON_STR = new BigResultCode(20, "将json对象转化为字符串出错！");
	public final static BigResultCode ERROR_JSON_OBJ = new BigResultCode(21, "将json字符串转化为对象出错！");
	public final static BigResultCode ERROR_JSON_LIST = new BigResultCode(21, "将json字符串转化为List出错！");
	//
	public final static BigResultCode ERROR_STR_DOUBLE = new BigResultCode(30, "将字符串[%s]转化为数字出错！");
	public final static BigResultCode ERROR_OBJ_DOUBLE = new BigResultCode(31, "空对象不能转化为数字！");
	public final static BigResultCode ERROR_PK_LEN = new BigResultCode(32, "主键[%s]的最大长度不能超过[%d]！");
	public final static BigResultCode ERROR_PINYIN = new BigResultCode(33, "中文[%s]转拼音出错！");
	//
	public final static BigResultCode ERROR_VELOCITY_NULL = new BigResultCode(40, "模板引擎不能为空！");
	public final static BigResultCode ERROR_VELOCITY_TMPL = new BigResultCode(41, "模板[%s]不存在！");
	public final static BigResultCode ERROR_VELOCITY_TMPL_STR = new BigResultCode(42, "将模板[%s]转化为字符串时出错！");
	public final static BigResultCode ERROR_VELOCITY_TMPL_OUTSTREAM = new BigResultCode(43, "将模板[%s]转化为输出流时出错！");
	public final static BigResultCode ERROR_VELOCITY_TMPL_FILE_EXIST = new BigResultCode(44, "模板[%s]转化的目标文件[%s]不存在！");
	public final static BigResultCode ERROR_VELOCITY_TMPL_FILE = new BigResultCode(45, "将模板[%s]转化为文件[%s]时出错！");
	public final static BigResultCode ERROR_VELOCITY_PROP = new BigResultCode(46, "设置模板引擎参数时出错！");
	public final static BigResultCode ERROR_VELOCITY_TMPLSTR = new BigResultCode(47, "解析模板字符串[%s]时出错！");
	public final static BigResultCode ERROR_VELOCITY_DIR = new BigResultCode(48, "获取模板文件目录出错！");
	public final static BigResultCode ERROR_MD5 = new BigResultCode(49, "将[%s]md5加密出错！");
	public final static BigResultCode ERROR_MAXNO = new BigResultCode(50, "编号已经是最大，无法获取下一个！");
	public final static BigResultCode ERROR_NO = new BigResultCode(51, "编号[%s]格式非法！");
	public final static BigResultCode ERROR_FORMAT = new BigResultCode(52, "[%s]数据格式非法或者暂不支持，正确的格式为：%s！");
	
	public final static BigResultCode ERROR_REQ_FILE = new BigResultCode(80, "从request中解析文件列表出错！");
	public final static BigResultCode ERROR_REQ_FORMVALUE = new BigResultCode(81, "从request中获取表单字段[%s]的值出错！");
	public final static BigResultCode ERROR_FILE_WRITE = new BigResultCode(82, "写入文件出错：[%s]！");

	public static final BigResultCode ERR_SETTER = new BigResultCode(120, "调用SETTER失败！");

	public static final BigResultCode ERR_CONSTRUCTOR = new BigResultCode(121, "构造方法调用失败！");
	public static final BigResultCode ERR_SET_FIELD = new BigResultCode(122, "通过反射设置实体类的字段值调用失败！");

	public static final BigResultCode EXCEPTION_COMM_NO_DATA_IN_SHEET = new BigResultCode(123, "sheet页没有数据！");
	public static final BigResultCode EXCEPTION_COMM_EXCEL_PARSE = new BigResultCode(124, "excel解析异常！");
	public static final BigResultCode EXCEPTION_COMM_CELL_FORMAT = new BigResultCode(125, "单元格式异常！");
	public static final BigResultCode EXCEPTION_COMM_EXCEL_CELL_NULL = new BigResultCode(126, "excel单元格为空！");
	public static final BigResultCode EXCEPTION_COMM_EXCEL_WRITE_FILE= new BigResultCode(127, "excel写入文件异常！");
	public static final BigResultCode EXCEPTION_COMM_EXCEL_WRITE_FAILURE= new BigResultCode(128, "excel写入失败！");

	private BigResultCode code = BigResultCode.getUnknownCode();

	public BigResultCode getCode() {
		return code;
	}

	/**
	 *
	 * @return
	 */
	public String getMessage() {
		return code.getMsg();
	}

	/**
	 *
	 */
	public BigException() {
		super();
	}

	/**
	 *
	 * @param code
	 * @param args
	 */
	public BigException(BigResultCode code, Object... args) {
		super();
		this.code = code.cloneCode().setMsgArgs(args);
	}

	/**
	 *
	 * @param cause
	 * @param code
	 * @param args
	 */
	public BigException(Throwable cause, BigResultCode code, Object... args) {
		super(cause);
		this.code = code.cloneCode().setMsgArgs(args);
	}
}
